package org.gikolet.ch2.android.io;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.IllegalCharsetNameException;
import java.nio.charset.UnsupportedCharsetException;

import org.gikolet.ch2.data.Res;
import org.gikolet.ch2.io.ResesReader;

public class LocalDatReader implements ResesReader {

	private Ch2DatInputStreamParser parser;

	public LocalDatReader(File file, String charsetName)
			throws IllegalCharsetNameException, UnsupportedCharsetException,
			FileNotFoundException, IOException {

		this(file, Charset.forName(charsetName));
	}

	public LocalDatReader(File file, Charset charset)
			throws FileNotFoundException, IOException {
		this.parser = new Ch2DatInputStreamParser(new FileInputStream(file), charset);
	}

	public Res read() throws IOException {
		return this.parser.read();
	}

	public String getSubject() throws IOException {
		return this.parser.getSubject();
	}

	public int getReadResCount() {
		return this.parser.getReadResCount();
	}

	public long getContentLength() {
		return this.parser.getContentLength();
	}

	public long getReadContentLength() {
		return this.parser.getReadContentLength();
	}

	public void close() throws IOException {
		this.parser.close();
	}
}
